package pe.gob.bcrp.sgci.gestion.reportes.model.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ejb.Stateless;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

import pe.gob.bcrp.sgci.gestion.reportes.model.dao.ReporteVersionDAO;
import pe.gob.bcrp.sgci.gestion.reportes.model.entity.ReporteVersion;

@Stateless
public class ReporteVersionDAOImpl extends DAOImpl<ReporteVersion> implements ReporteVersionDAO {
	
	EntityManagerFactory factory;
	//EntityManager em;
	Map<String, String> properties = new HashMap<String, String>();
	
	public ReporteVersionDAOImpl() {
		factory = Persistence.createEntityManagerFactory("dssgcipool");
		//em = factory.createEntityManager();
		properties.put("eclipselink.jdbc.exclusive-connection.mode", "Always");
		properties.put("eclipselink.jdbc.exclusive-connection.is-lazy", "false");
	}
	
	
	public void add(ReporteVersion reporteVersion) {		
		//properties.put("javax.persistence.jdbc.user", user);
		//properties.put("javax.persistence.jdbc.password", password);		

		em = factory.createEntityManager(properties);

		em.getTransaction().begin();  
		em.persist(reporteVersion);
		em.getTransaction().commit();
		
		em.clear();
		em.close();
        //em.persist(object);
    }
}
